﻿using ImModels.View;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ImTest
{
    public partial class FrmCreateGroup : Form
    {
        public CreateGroupReq addUser = new CreateGroupReq();

        public FrmCreateGroup()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            addUser = new CreateGroupReq()
            {
                FullName = tb_fullName.Text.Trim(),
                Comment = tb_Comment.Text.Trim(),
                HeadImg = tb_HeadImg.Text.Trim(),
                ExJson = tb_ExJson.Text.Trim(),
                Flags = tb_Flags.Text.Trim(),
                ToUser = new List<ToGroupUser>()
            };

            foreach (var item in tb_ToUser.Text.Trim().Split('\n'))
            {
                if (string.IsNullOrWhiteSpace(item))
                {
                    continue;
                }
                var toUserAry = item.Split('\\');
                addUser.ToUser.Add(new ToGroupUser()
                {
                    BizUserId = toUserAry[0],
                    FullName = toUserAry[1],
                    JobName = toUserAry[2],
                    HeadImg = toUserAry[3]
                });
            }
            this.DialogResult = DialogResult.OK;
            this.Hide();
        }

        private void FrmCreateGroup_Load(object sender, EventArgs e)
        {
            var rad = new Random().Next(1, 100);
            tb_fullName.Text = "群-" + rad;
            tb_Comment.Text = "这是模拟的群摘要-" + rad;
        }
    }
}
